package sync.hw.teacher.demo01;

/**
 * @author lwj
 * @date 2025-03-13
 * @vesion 1.0.0
 */
public class MyRunnable implements Runnable{
    /**
     * 账号
     */
    private Account account;
    /**
     * 取钱用户
     */
    private String user;
    /**
     * 取钱金额
     */
    private double money;
    /**
     * 锁对象 -
     */
    private static final Object LOCK = new Object();

    // 构造方法
    public MyRunnable() {}
    public MyRunnable(Account account, String user, double money) {
        this.account = account;
        this.user = user;
        this.money = money;
    }

    @Override
    public void run() {
        // 同步块
        synchronized (LOCK){
            account.getMoney(user,money);
        }
    }
}
